package com.ywgt.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyThread thread=new MyThread();
        FutureTask<String> task = new FutureTask<>(thread);
        new Thread(task).start();
        String s = task.get();
        System.out.println(s);
    }
}
class MyThread implements Callable<String>{
    @Override
    public String call() throws Exception {
        return "hello world";
    }
}